/// Coder: Jose Ricardo Mello Viana - 2008
/// Bugs? e-mail me: zezim.ricardo@gmail.com

#ifndef MOTION_H_
#define MOTION_H_

#include "typedefs.h"

class Motion {
public:
   /// Constructor Default
   Motion();

   /// Destructor Default
   virtual ~Motion();   

   /// Gets i'th frame of motion
   /// @param i given index
   /// @return corresponding frame
   inline PoseTransformations getFrame(int i){ return frames[i - 1]; };
   
   /// Gets the size of motion
   /// @return size of motion
   inline int getMotionSize(){ return frames.size(); };
   
   /// Insert a frame in motion
   /// @param pt given pose transformations
   void insertFrame(PoseTransformations pt);
   
   /// Sets the degree angle unit
   /// @param d identify degree unit
   void setDegree(bool d){ isDeg = d; };
   
   /// Gets the degree angle unit
   /// @return true if degree is the angle unit
   bool isDegree(){ return isDeg; };

private:
   vector<PoseTransformations>         frames; /// vector of frames in the animation
   bool                                isDeg;
};

/// Output operator
inline ostream & operator <<(std::ostream &os, Motion *s) {
   for (int i = 1; i < s->getMotionSize(); i++) {
      os << i << endl;
      PoseTransformations f = s->getFrame(i);
      PoseTransformations::iterator it;
      for (it = f.begin(); it != f.end(); it++) {
         os << it->first << ": ";
         Transformations v = it->second;
         for (int j = 0; j < v.size(); j++) {
            os << v[j] << ", ";
         }
         os << endl;
      }      
   }
   return os;
}

/// Output operator
inline ostream & operator <<(std::ostream &os, PoseTransformations p) {
   PoseTransformations::iterator it;
   for (it = p.begin(); it != p.end(); it++) {
      os << it->first << ": ";
      Transformations v = it->second;
      for (int j = 0; j < v.size(); j++) {
         os << v[j] << ", ";
      }
   }
   os << endl;
   return os;
}

#endif /*MOTION_H_*/
